package com.fortune.rainshinecommon.base;

import com.fortune.rainshinecommon.enums.RespStatusEnum;

import java.io.Serializable;


public class MsgModel<T> implements Serializable {

    private static final long serialVersionUID = 4054892350748145972L;

    /**
     * @Fields msg : 消息
     */
    private String msg;
    /**
     * @Fields code : 调用状态 0.成功 1.失败
     */
    private int code;
    /**
     * @Fields data : 返回数据
     */
    private T data;

    /**数据总量*/
    private long count;






    public MsgModel(){

    }
    public MsgModel(String msg){
        this.msg=msg;
    }
    public MsgModel(String msg,int code){
        this.msg=msg;
        this.code=code;
    }
    public MsgModel(String msg,RespStatusEnum statusEnum){
        this.msg=msg;
        this.code=statusEnum.ordinal();
    }
    public MsgModel(String msg,int code,T data){
        this.msg=msg;
        this.code=code;
        this.data=data;
    }
    public MsgModel(String msg, RespStatusEnum statusEnum, T data,long count){
        this.msg=msg;
        this.code=statusEnum.ordinal();
        this.data=data;
        this.count=count;
    }
    public String getMsg() {
        return msg;
    }
    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }
    public void setData(T data) {
        this.data = data;
    }

    public boolean isSuccess(){
        if(RespStatusEnum.SUCCESS.ordinal() == code || RespStatusEnum.SUCCESS.ordinal() == code){
            return true;
        }
        return false;
    }
    public int getCode() {
        return code;
    }
    public void setCode(int code) {
        this.code = code;
    }


    public long getCount() {
        return count;
    }

    public void setCount(long count) {
        this.count = count;
    }
}
